// 用户相关类型定义

export interface User {
  id: string
  username: string
  name: string
  email: string
  department_id?: string
  department?: string
  position?: string
  phone?: string
  avatar?: string
  bio?: string
  roles: string[]
  system_roles?: string[]
  permissions?: string[]
  status: string
  is_verified: boolean
  last_login?: string
  created_at: string
  updated_at: string
  login_count?: number
}

export interface CreateUserParams {
  username: string
  name: string
  email: string
  password: string
  department?: string
  position?: string
  phone?: string
  roles: string[]
  status?: string
}

export interface UpdateUserParams {
  username?: string
  name?: string
  email?: string
  department?: string
  position?: string
  phone?: string
  avatar?: string
  bio?: string
  roles?: string[]
  status?: string
}

export interface UserProfile {
  id: string
  username: string
  email: string
  name?: string
  phone?: string
  avatar?: string
  bio?: string
  location?: string
  website?: string
  created_at: string
  updated_at: string
}

export interface ChangePasswordParams {
  old_password: string
  new_password: string
  confirm_password: string
}

export interface ResetPasswordParams {
  email: string
}

export interface UserStats {
  total_users: number
  active_users: number
  inactive_users: number
  new_users_this_month: number
  user_growth_rate: number
}

export interface Role {
  id: string
  name: string
  display_name: string
  description?: string
  permissions: string[]
  is_active: boolean
  created_at: string
  updated_at: string
}

export interface Permission {
  id: string
  name: string
  display_name: string
  description?: string
  resource: string
  action: string
  created_at: string
  updated_at: string
}

export interface UserListParams {
  page?: number
  size?: number
  skip?: number
  limit?: number
  search?: string
  username?: string
  email?: string
  phone?: string
  role?: string
  status?: string
  department?: string
  sort_by?: string
  sort_order?: 'asc' | 'desc'
}

export interface UserListResponse {
  items: User[]
  total: number
  page: number
  size: number
  pages: number
}

// 用户状态枚举
export enum UserStatus {
  ACTIVE = 'active',     // 激活
  INACTIVE = 'inactive', // 禁用
  DELETED = 'deleted'    // 已删除（前端不显示）
}

// 用户角色枚举
export enum UserRole {
  ADMIN = 'admin',
  PROJECT_MANAGER = 'project_manager',
  DEVELOPER = 'developer',
  TESTER = 'tester',
  VIEWER = 'viewer'
}

// 权限枚举
export enum PermissionAction {
  CREATE = 'create',
  READ = 'read',
  UPDATE = 'update',
  DELETE = 'delete',
  MANAGE = 'manage'
}

export enum PermissionResource {
  USER = 'user',
  PROJECT = 'project',
  TASK = 'task',
  REQUIREMENT = 'requirement',
  DOCUMENT = 'document',
  SYSTEM = 'system'
}